package com.bdqn.zhao.controller;


import com.bdqn.zhao.pojo.*;
import com.bdqn.zhao.service.SysDeptService;
import com.bdqn.zhao.service.SysDistrictsService;
import com.bdqn.zhao.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2023-04-24
 */
@Controller
@RequestMapping("/sysDept")
public class SysDeptController {

    @Autowired
    public SysDeptService sysDeptService;

    /**
     * 全查操作
     *
     * @return
     */
    @GetMapping("/dept")
    public List seleceAll() {
        return sysDeptService.selectAll();
    }

    /**
     * 根据id详细查询
     *
     * @param id
     * @return
     */
    @GetMapping("/dept/{id}")
    public SysDept selectbyid(@PathVariable int id) {
        SysDept selectbyid = sysDeptService.selectbyid(id);
        return selectbyid;
    }

    /**
     * 根据id删除部门
     *
     * @param id
     * @return
     */
    @ResponseBody
    @GetMapping("/dept/del/{id}")
    public int delectSysuer(@PathVariable int id) {
        return sysDeptService.delectSysuer(id);
    }

    /**
     *
     *
     * @param sysDept
     * @return
     */
    @PostMapping("/dept/update/pwd")
    public int update(SysDept sysDept) {
        return sysDeptService.updatePwd(sysDept);
    }

    @ResponseBody
    @PostMapping("/dept/add")
    public int sysuerAdd(SysDept sysDept) {
        return sysDeptService.sysDeptrAdd(sysDept);

    }

    @GetMapping("/dept/mohu/{pageNum}/{pageSize}")
    public List<SysDept> fuzzy(@PathVariable Integer pageNum,
                                    @PathVariable Integer pageSize,String status,String deptName){
        List<SysDept> fuzzy = sysDeptService.fuzzy(pageNum,pageSize,status, deptName);
        return fuzzy;
    }
}

